home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / GENetReleaseƒ / Extras / Motion.h < prev    next >
Text File  |  1994-03-07  |  1KB  |  60 lines

  1. /*
  2.     Motion.h
  3.     
  4.     Simple motion routines for Graphic Elements
  5.     
  6.     Copyright 1993 by Al Evans. All rights reserved.
  7.     
  8.     11/3/93
  9. */
  10.  
  11. /*
  12.     These routines are just some quick hacks to show how "laws of motion" can
  13.     be applied to Graphic Elements.
  14.     
  15.     They should NOT be used in real software!
  16. */
  17.  
  18. #ifndef MOTIONPROCS
  19. #define MOTIONPROCS
  20.  
  21. #ifdef applec
  22. #ifndef __cplusplus
  23. #ifndef PRELOAD
  24. #pragma load "::ToolKit.precompile"
  25. #define PRELOAD
  26. #endif
  27. #endif
  28. #endif
  29.  
  30. #include "DispCtrl.h"
  31.  
  32. typedef struct {
  33.     Rect    limitRect;
  34.     Point    currMotion;
  35.     long    friction;    //coeff. of friction, %
  36.     long    frictAcc;    //Actually fixed-point
  37.     long    elasticity; //coeff. of elasticity
  38. } MotionParams, *MParamPtr;
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. //Initialize MotionParams record
  45. void InitMotion(MParamPtr motionRec, short percentFriction, short percentElasticity);
  46.  
  47. //Returns direction (right, left, up, down only) of collision with limitRect
  48. GEDirection CheckLimits(Rect *spriteRect, Rect *limitRect);
  49.  
  50. //Modifies motion->currMotion to reflect motion->friction
  51. void DoFriction(MParamPtr motion);
  52.  
  53. //Modifies motion->currMotion to reflect bounce in direction, taking into account motion->elasticity
  54. void DoBounce(VHSelect direction, MParamPtr motion);
  55.  
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59.  
  60. #endif